Skip to content

Conversation

kfranqueiro
Copy link
Contributor

@kfranqueiro kfranqueiro commented Sep 12, 2025

This removes:

  • All xml:space attributes from pre elements, which are no longer needed since the XSLT build system was retired
  • All att, el, obj, prop, and propval classes from code elements, which don't have any associated styles
  • All language-* classes from inline code elements, which have no effect because highlight.js does not run on them
  • Most language-* classes on code elements inside pre, except where highlight.js guesses incorrectly without it

This fixes the following highlight.js instances, which had been manually overridden to the wrong values:

  • html incorrectly overridden to css in C35 (2x), C36, F2, F100
  • html incorrectly overridden to javascript in SCR14, F3, F37, F50
  • css incorrectly overridden to html in ARIA24 (2x), G188
  • php-template incorrectly overridden to html in C29 (2x)
  • php-template (with HTML also highlighted) incorrectly overridden to php (HTML not highlighted) in SVR3, SVR4

All other instances are unaffected, as auto-detection matches the removed override.

Note this will also benefit from #4520, which will further prevent slightly-inaccurate-but-mostly-harmless auto-detection of CSS as Less (which is present in the external highlight.js loaded in those files, but not present in our own highlight.min.js).

How I determined where language-* classes were required

  1. Add some logging to highlight.js before running highlightAll:
    hljs.addPlugin({
      "after:highlightElement": ({ result, text }) => {
        console.log(`hljs: ${result.language} ${result.relevance} ${JSON.stringify(text.slice(0, 30))}`);
      }
    });
  2. Run all pages with pre code through playwright:
    import { load } from "cheerio";
    import { readFile } from "fs/promises";
    import { join } from "path";
    import { chromium, devices } from "playwright";
    import { glob } from "tinyglobby";
    
    const baseUrl = "http://localhost:8080/";
    const cwd = "../wcag/_site";
    const paths = (
      await glob(["techniques/**/*.html", "understanding/**/*.html"], { cwd })
    ).sort();
    
    const browser = await chromium.launch();
    const context = await browser.newContext(devices["Desktop Chrome"]);
    
    for (const path of paths) {
      // Skip files that don't actively use hljs (cuts run time in half)
      const $ = load(await readFile(join(cwd, path)));
      if (!$("pre code").length) continue;
    
      const page = await context.newPage();
      page.on("console", (message) => {
        const text = message.text();
        if (text.startsWith("hljs: ")) console.log(path, text);
      });
      await page.goto(baseUrl + path);
      await page.close();
    }
    
    await context.close();
    await browser.close();
  3. Pipe the above script to a file, run before and after the changes, and compare the results:
    • For diffs where the "before" was correct, I restored the override (backed out the removal)
    • For diffs where the "after" is correct, the override was incorrect and removing it fixes highlighting (see list of fixes above)

Copy link

netlify bot commented Sep 12, 2025

Deploy Preview for wcag2 ready!

Name Link
🔨 Latest commit 9434d3c
🔍 Latest deploy log https://app.netlify.com/projects/wcag2/deploys/68c82af84cb77b00086b91d7
😎 Deploy Preview https://deploy-preview-4611--wcag2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kfranqueiro kfranqueiro self-assigned this Sep 12, 2025
</head>
<body>
<h1>Using <code class="language-html">role=heading</code> to identify headings</h1>
<h1>Using <code>role=heading</code> to identify headings</h1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be one of those inline uses that would benefit from highlighting, if that's possible

<p>The purpose of this technique is to provide a way for Assistive Technologies (AT) to identify
a piece of content as a heading. Applying <code class="language-html">role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code class="language-html">role="heading"</code> property must be paired with the <code class="language-html">aria-level</code> property to define the heading level.</p>
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code class="language-html">h1</code> element, rather than using <code class="language-html">&lt;div role="heading" aria-level="1"&gt;</code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code class="language-html">&lt;div role="heading" aria-level="1"&gt;</code> will not be styled as a heading, because the underlying element is a <code class="language-html">div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p>
a piece of content as a heading. Applying <code>role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code>role="heading"</code> property must be paired with the <code>aria-level</code> property to define the heading level.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the role ones may benefit from highlighting if possible

a piece of content as a heading. Applying <code class="language-html">role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code class="language-html">role="heading"</code> property must be paired with the <code class="language-html">aria-level</code> property to define the heading level.</p>
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code class="language-html">h1</code> element, rather than using <code class="language-html">&lt;div role="heading" aria-level="1"&gt;</code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code class="language-html">&lt;div role="heading" aria-level="1"&gt;</code> will not be styled as a heading, because the underlying element is a <code class="language-html">div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p>
a piece of content as a heading. Applying <code>role="heading"</code> to an element causes an AT (like a screen reader) to treat it as though it were a heading. The <code>role="heading"</code> property must be paired with the <code>aria-level</code> property to define the heading level.</p>
<p>When possible, <a href="https://www.w3.org/TR/using-aria/#rule1">use native heading markup</a>. For example, it is preferable to use an <code>h1</code> element, rather than using <code>&lt;div role="heading" aria-level="1"&gt;</code>. Native <abbr title="HyperText Markup Language">HTML</abbr> elements have implicit styling and features that won't necessarily be replicated with ARIA equivalents. For instance, heading elements will have specific styling adjustments made when viewing a page in a browser's Reader Mode. Whereas a <code>&lt;div role="heading" aria-level="1"&gt;</code> will not be styled as a heading, because the underlying element is a <code>div</code>. ARIA only modifies the way an element is exposed to assistive technology, it does nothing to change the implicit style or functionality of the element it is applied to.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the examples with div role may benefit from highlighting if possible

<h3>Simple headings</h3>
<p>This example demonstrates how to implement headings using <code class="language-html">role="heading"</code> and <code class="language-html">aria-level</code>.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div role="heading" aria-level="2"&gt;Global News Items&lt;/div&gt;
<p>This example demonstrates how to implement headings using <code>role="heading"</code> and <code>aria-level</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role ones may benefit from highlighting


<p>This example demonstrates how to implement a level 7 heading using <code class="language-html">role="heading"</code> and the <code class="language-html">aria-level</code> attribute. Since HTML only supports headings up to level 6, there is no native element to provide these semantics.</p>
<pre xml:space="preserve"><code class="language-html">&lt;h5&gt;Fruit Trees&lt;/h5&gt;
<p>This example demonstrates how to implement a level 7 heading using <code>role="heading"</code> and the <code>aria-level</code> attribute. Since HTML only supports headings up to level 6, there is no native element to provide these semantics.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role one may benefit from highlighting

<h3>Procedure</h3>
<ol>
<li>Examine each element with the attribute <code class="language-html">role="heading"</code>.</li>
<li>Examine each element with the attribute <code>role="heading"</code>.</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may benefit from highlighting

<p>In some situations, elements can be given the attribute <code>aria-label</code> to provide an accessible name for situations when there is no visible label due to a chosen design approach or layout but the context and visual appearance of the control make its purpose clear.</p>

<p>In other situations, elements can be given the attribute <code class="language-html">aria-label</code> to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code class="language-html">div</code> set to <code class="language-html">contentEditable</code> is used instead of native form elements such as <code class="language-html">input type="text"</code> or <code class="language-html">textarea</code> in order to provide a richer text editing experience.</p>
<p>In other situations, elements can be given the attribute <code>aria-label</code> to provide an accessible name when the native HTML labeling element is not supported by the control - for example, when a <code>div</code> set to <code>contentEditable</code> is used instead of native form elements such as <code>input type="text"</code> or <code>textarea</code> in order to provide a richer text editing experience.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input type may benefit from highlighting


<p>On a page, a link displays a pop-up box (a <code class="language-html">div</code>) with additional information. The 'close' element is implemented as a <code class="language-html">button</code> containing merely the letter 'X'. The property <code class="language-html">aria-label="close"</code> is used to provide an accessible name to the <code class="language-html">button</code>.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div id="box"&gt;
<p>On a page, a link displays a pop-up box (a <code>div</code>) with additional information. The 'close' element is implemented as a <code>button</code> containing merely the letter 'X'. The property <code>aria-label="close"</code> is used to provide an accessible name to the <code>button</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-label may benefit from highlighting

<p>The group can be labeled using <code class="language-html">aria-labelledby</code>.</p>
<p>This technique is not meant for wrapping all controls on a form within a single container with <code class="language-html">role="group"</code>.</p>
<p>The objective of this technique is to mark up a set of related controls within a form as a group. Any label associated with the group also serves as a common label or qualifier for individual controls in the group. Assistive technologies can indicate the start and end of the group and the group's label as one navigates into and out of the group. This is a viable alternative for grouping form controls programmatically when the user interface's design makes it difficult to employ the <code>fieldset</code> / <code>legend</code> technique (<a href="../html/H71">H71</a>).</p>
<p>For a group of radio buttons, one should use <code>role="radiogroup"</code> instead of <code>role="group"</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role ones may benefit from highlighting

<p>The objective of this technique is to mark up a set of related controls within a form as a group. Any label associated with the group also serves as a common label or qualifier for individual controls in the group. Assistive technologies can indicate the start and end of the group and the group's label as one navigates into and out of the group. This is a viable alternative for grouping form controls programmatically when the user interface's design makes it difficult to employ the <code>fieldset</code> / <code>legend</code> technique (<a href="../html/H71">H71</a>).</p>
<p>For a group of radio buttons, one should use <code>role="radiogroup"</code> instead of <code>role="group"</code>.</p>
<p>The group can be labeled using <code>aria-labelledby</code>.</p>
<p>This technique is not meant for wrapping all controls on a form within a single container with <code>role="group"</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting

<h3>Social Security Number</h3>
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code class="language-html">role="group"</code>.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div role="group" aria-labelledby="ssn1"&gt;
<p>Social security number fields which are nine digits long and broken up into three segments can be grouped using <code>role="group"</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting


<p>This example demonstrates use <code class="language-html">role=radiogroup</code>. Note also that the radio buttons are custom controls with <code class="language-html">role=radio</code>. One may optionally employ CSS to place a border around groups of such fields to visually reinforce the group relationship. The CSS properties are available below the form.</p>
<pre xml:space="preserve"><code class="language-html">&lt;h3&gt;Set Alerts for your Account&lt;/h3&gt;
<p>This example demonstrates use <code>role=radiogroup</code>. Note also that the radio buttons are custom controls with <code>role=radio</code>. One may optionally employ CSS to place a border around groups of such fields to visually reinforce the group relationship. The CSS properties are available below the form.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roles may benefit from highlighting

<ol>
<li> Check that the group of logically related input or select elements are contained within an element with <code class="language-html">role=group</code>, or <code class="language-html">role=radiogroup</code> depending on the type of elements the group contains.</li>
<li> Check that this group has an accessible name defined using <code class="language-html">aria-label</code> or <code class="language-html">aria-labelledby</code>.</li>
<li> Check that the group of logically related input or select elements are contained within an element with <code>role=group</code>, or <code>role=radiogroup</code> depending on the type of elements the group contains.</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roles may benefit from highlighting

<p>Technologies that support <a href="https://www.w3.org/TR/wai-aria/">Accessible Rich Internet Applications (WAI-ARIA)</a>. </p>
</section><section id="description"><h2>Description</h2>
<p>The purpose of this technique is to alert people that an input error has occurred. Using <code class="language-html">role="alertdialog"</code> creates a notification. This notification should be modal with the following characteristics:
<p>The purpose of this technique is to alert people that an input error has occurred. Using <code>role="alertdialog"</code> creates a notification. This notification should be modal with the following characteristics:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting


<p>This example shows how a notification using <code class="language-html">role="alertdialog"</code> can be used to notify someone they have entered invalid information.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div role="alertdialog" aria-labelledby="alertHeading"&gt;
<p>This example shows how a notification using <code>role="alertdialog"</code> can be used to notify someone they have entered invalid information.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting

<section class="procedure"><h3>Procedure</h3>
<ol>
<li>Determine that an empty error container <code class="language-html">role=alert</code> or <code class="language-html">aria-live=assertive</code> attribute is present in the DOM at page load.</li>
<li>Determine that an empty error container <code>role=alert</code> or <code>aria-live=assertive</code> attribute is present in the DOM at page load.</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role and aria-live may benefit from highlighting

<div class="note">
<p>Use of <code class="language-html">aria-required="true"</code> might be beneficial even when an asterisk or other text symbol is programmatically associated with the field as it may reinforce its <code class="language-html">required</code> property for some assistive technology users.</p>
<p>The fact that the element is required is often visually presented (such as a sign or symbol after the control). Using the <code class="language-html">aria-required</code> property in addition to the visual presentation makes it much easier for user agents to pass on this important information to the user in a user agent-specific manner. Refer to <a href="https://www.w3.org/TR/html-aria/">ARIA in HTML</a> for information on how to provide WAI-ARIA States and Properties with HTML. WAI-ARIA States and Properties are compatible with other languages as well; refer to documentation in those languages. </p>
<p>Use of <code>aria-required="true"</code> might be beneficial even when an asterisk or other text symbol is programmatically associated with the field as it may reinforce its <code>required</code> property for some assistive technology users.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-required may benefit from highlighting


<p>This example uses custom radio buttons with <code class="language-html">role=radio</code>. The CSS properties are available below the form.</p>
<pre xml:space="preserve"><code class="language-html">&lt;form&gt;
<p>This example uses custom radio buttons with <code>role=radio</code>. The CSS properties are available below the form.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting


<p>A section on the home page of a news website that contains a poll that changes every week is marked up with <code class="language-html">role="region"</code>. The <code class="language-html">h3</code> above the form is referenced as the region's name using <code class="language-html">aria-labelledby</code>.</p>
<pre xml:space="preserve"><code class="language-html">&lt;div role="region" aria-labelledby="pollhead"&gt;
<p>A section on the home page of a news website that contains a poll that changes every week is marked up with <code>role="region"</code>. The <code>h3</code> above the form is referenced as the region's name using <code>aria-labelledby</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting


<p>A user can expand links on a bank website after logging in to see details of term deposit accounts. The details are within a <code class="language-html">span</code> marked up with <code class="language-html">region</code> role. The heading for the region has <code class="language-html">role=heading</code> and is included in the <code class="language-html">aria-labelledby</code> that names the region.</p>
<pre xml:space="preserve"><code class="language-html">&lt;ol&gt;
<p>A user can expand links on a bank website after logging in to see details of term deposit accounts. The details are within a <code>span</code> marked up with <code>region</code> role. The heading for the region has <code>role=heading</code> and is included in the <code>aria-labelledby</code> that names the region.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting

</section><section id="tests"><h2>Tests</h2>
<section class="procedure"><h3>Procedure</h3>
<p>For each section marked up with <code class="language-html">role="region"</code>:</p>
<p>For each section marked up with <code>role="region"</code>:</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role may benefit from highlighting

patrickhlauke and others added 11 commits September 13, 2025 20:00
This reverts commit e33ab7c.

I indicated in the PR description why I intentionally did not change these.
This reverts commit 053cf5d.

(Java shouldn't be highlighted because we don't have the syntax installed for it)
This reverts commit 1247a8e.

(Java shouldn't be highlighted because we don't have the syntax installed for it)
This reverts commit fe917ab.

(I had intentionally removed these, because our highlight.js instance does not have syntax highlighting for the relevant languages)
This reverts commit 6ab4af6.

(I had intentionally left these alone, because our highlight.js instance does not have the relevant languages and these techniques are obsolete)
And a few other fixes related to Patrick's edits
@patrickhlauke
Copy link
Member

out of interest then ... why do we have those naked <pre>s ? they do contain code, so semantically they should have <code> wrappers?

@kfranqueiro
Copy link
Contributor Author

kfranqueiro commented Sep 15, 2025

@patrickhlauke I backed out a few of your changes, as some of them contradicted changes I intentionally did not make:

  • A few instances of class="language-html" are required, otherwise highlight.js incorrectly guesses CSS (as per the "Most ..." bullet in my PR description)
  • I intentionally did not touch Flash or Silverlight techniques both because they're obsolete and because our instances of highlight.js does not include support for e.g. ActionScript and C#. I left the SVR examples unhighlighted for the latter reason as well. (I really thought I'd left a note about this in my description but I don't see it there - edit: oops, I was thinking of my remark at the end of the description of Converge on default pre > code highlight.js usage #4604)

I've looked through some of your comments RE instances where syntax highlighting inline code tags may be useful. My suspicion is that in the majority of those cases, there won't be enough context for highlight.js to highlight properly even if we do specify language (e.g. role="foo" is an attribute inside of a tag, but the tag does not exist). I will test to see what happens...

Edit: I am also adding to my to-do list to investigate updating our build of highlight.js to support the languages I mention above that weren't in ours, in which case I can test un-reverting Patrick's Flash/Silverlight/SVR changes, either here or in a separate branch (because I am wary of increasing the scope of this PR).

@kfranqueiro
Copy link
Contributor Author

kfranqueiro commented Sep 15, 2025

I've performed some testing with regard to highlighting inline <code> elements:

  • HTML tag names without angle brackets, or attribute keys/values out-of-context, will not be accurately highlighted, even when language is forced to HTML
  • Entire HTML tags can be highlighted, but typically require explicit class="language-html"
  • JavaScript variables or function invocations (with () at the end) can be highlighted, but typically require explicit class="javascript"
    • Note that function invocations will end up highlighted a different color than standalone variable names, which may look confusing out-of-context

As an example of the first bullet, see how every <code> element in this paragraph is the same color regardless of its content, even though they have class="language-html", because highlight.js doesn't find anything meaningful to latch onto:
A paragraph containing multiple inline code elements. All of them are the same color, regardless of their content, due to highlight.js not finding any meaningful tokens.

The vast majority of cases of inline <code> tags involve a single word or key=value phrase. Even disregarding whether it is highlighted correctly, the addition of color will be negligible at best or confusing at worst. I have to figure there are reasons why highlight.js defaults to only focusing on full code blocks, and that its shipped styles are specifically designed only for that case.

I would much rather move ahead with removing classes from inline code tags to clean them up, than add highlight.js processing to them which opens a new can of worms with significant maintenance overhead. (Reminder: the cleanup causes no visual difference with what is currently published.)

If you're curious, here's a full list of inline code tags' contents and classes currently found on the main branch. (Note that a few of the longer instances are actually <p><code>, which are better off as <pre><code>; Patrick identified a few of those when he looked at this PR, and I will take another pass at that.)

@patrickhlauke
Copy link
Member

@kfranqueiro

intentionally did not touch Flash or Silverlight techniques both because they're obsolete and because our instances of highlight.js does not include support for e.g. ActionScript and C#. I left the SVR examples unhighlighted for the latter reason as well.

sure but semantically, those are code blocks, not just "there's some random preformatted content here, dunno". so from a markup point of view, regardless of highlighting or not, i feel like they should be wrapped in <code> (and yes, not that it makes a huge difference in practice, but just feels wrong not to)

@patrickhlauke
Copy link
Member

and sure, the cases where there's methods/attributes with ="..." values etc probably don't really really need highlighting, happy to live with them not being highlighted. this was more a lengthy futile exercise in "but what IF we wanted to go for highlighting"

@kfranqueiro
Copy link
Contributor Author

kfranqueiro commented Sep 15, 2025

sure but semantically, those are code blocks, not just "there's some random preformatted content here, dunno". so from a markup point of view, regardless of highlighting or not, i feel like they should be wrapped in <code> (and yes, not that it makes a huge difference in practice, but just feels wrong not to)

From the perspective of functional repercussions of highlight.js, we effectively have 2 options for cases that should not get syntax highlighting:

  • Wrap in <pre><code> but then also add class="no-highlight" so that highlight.js processes it but doesn't (incorrectly) syntax highlight it
  • Leave without <code> so that highlight.js does not process it at all

In the case of #4604, the <code> elements I'd removed were specifically in text techniques and instances of plain (non-code) text formatting, so I suppose in those cases the removal ends up semantically making sense. I see your point RE the "unsupported syntax" cases, so I'll pull further on those threads to see if we can instead update to support them properly, and then add back your commits. (I'm going to want to do a before/after using the Playwright script I posted above to check for any other unintended auto-detection changes.)

Sorry for initially yanking them this morning - I was trying to preserve the intended scope of this PR. I might still argue not to bother touching up the fully-obsolete Flash and Silverlight pages, but I will at least do an initial test as it relates to the server-side script techniques.

And thanks for poking around on the inline cases - indeed that bit was an experiment for the both of us.

@patrickhlauke
Copy link
Member

nah, all good. i think i fell down too much of a rabbithole on saturday and should have checked first before barging in all over your PR :)

@kfranqueiro
Copy link
Contributor Author

kfranqueiro commented Sep 18, 2025

I am planning to re-do this and split it into separate PRs:

  • PR 4621: Remove classes from inline code elements because they provide no benefit (see comment above; no visible changes)
    • PR 4623 based on the above: Apply Patrick's phrasing changes to code elements (changes prose content, should be reviewed by TF/WG)
  • PR 4624: Fix incorrect hljs override classes pointed out in this PR's description (changes syntax highlighting in a few code blocks)
  • PR 4627: Add missing hljs override classes to <pre><code> instances, and fix any <p><code>...</code></p> or <pre>-only instances that should be <pre><code> (changes/adds syntax highlighting to a few code blocks)
    • Within the same PR: update our hljs bundle to include missing languages that we reference (excluding C# and ActionScript, as there's no point in bloating the bundle only for obsolete Flash/SL techniques, which currently don't run through highlight.js)
  • PR: Remove xml:space="preserve" from pre elements (no visual changes)
    • Wait until all of the above land before doing this

The most notable change from this PR to the sequence I just outlined is that I will not be removing classes from <code> inside <pre>, but rather adding it where it is missing or correcting it where it is wrong. When I tested upgrading highlight.js and/or expanding the languages it supports, I noticed many autodetect outcomes shift, which has me thinking we are better off erring on the safe side for future upgrades by specifying syntax, which we have already been doing in the majority of cases.

@bruce-usab
Copy link
Contributor

Discussed on TF call 9/19/2025.

kfranqueiro added a commit that referenced this pull request Sep 24, 2025
This removes classes from `code` elements that appear inline within
prose.

These classes have no effect, and based on local testing, it would be
unrealistic to expect highlight.js to provide meaningful syntax
highlighting in the vast majority of these cases due to insufficient
context. See
#4611 (comment) for more
details.

I have looked over this changeset and also ran screenshot diffs; this
causes no visible changes.
kfranqueiro added a commit that referenced this pull request Sep 24, 2025
This fixes instances where we had specified the wrong `language-...`
class in `<pre><code class="...">`, causing highlight.js to highlight
code incorrectly.

(Originally fixed/reported in #4611, which is being split up and closed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants